import React, { useState } from 'react';
import {Button, message, Spin} from 'antd';
import EmptyLesson from '@/components/emptyLesson';
import FreeTimeTableForm from '@/components/freeTimeTableForm';
import { request } from "umi";
import styles from "../components/App.css";

export default function() {
  const [emptyLessonData, setEmptyLessonData] = useState([]);

  const postField = (values) => {
    const hide = message.loading('请求加载中...', 0);
    request('http://t.onionnet.work/api/getBlankTable', {
        method: 'post',
        data: values
      })
      .then(function(response) {
        hide();
        if (response){
          setEmptyLessonData(response.data);
        }
      })
  };
  return (
    <div>
      <div className="steps-content">
        {
          (()=>{
            if(emptyLessonData.length <= 0){
              return <FreeTimeTableForm onSuccess={postField} />;
            }else{
              return <EmptyLesson data={emptyLessonData} onReturnBack={() => setEmptyLessonData([])}/>;
            }
          })()
        }
      </div>
    </div>
  );
}
